<?php


namespace app\common\model;


use think\Model;

class GuildUserApplyModel extends Model
{
    protected $connection = 'db_live';

    // 类型
    const TYPE_CATE = [
        1 => '申请加入',
        2 => '退会',
        3 => '解约',
    ];

    public static function getTypeTextAttr($value, $data)
    {
        return isset(self::TYPE_CATE[$data['type']]) ? self::TYPE_CATE[$data['type']] : '';
    }

    public function user()
    {
        return $this->hasOne(UserModel::class, 'id', 'uid')->with(['profile'])->field('id,account,avatar,nick_name');
    }

    public function guild()
    {
        return $this->hasOne(GuildModel::class, 'id', 'guild_id')->field('id,name');
    }
}